package org.tis.tools.abf.module.sys.service;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import org.tis.tools.abf.module.sys.controller.request.SysDictDefaultValueRequest;
import org.tis.tools.abf.module.sys.controller.request.SysDictDelRequest;
import org.tis.tools.abf.module.sys.controller.request.SysDictFilterQueryRequest;
import org.tis.tools.abf.module.sys.entity.SysDict;
import org.tis.tools.abf.module.sys.entity.vo.SysDictApiDetail;
import org.tis.tools.abf.module.sys.entity.vo.SysDictDetail;
import org.tis.tools.abf.module.sys.entity.vo.SysDictHandelDetail;
import org.tis.tools.abf.module.sys.exception.SysManagementException;

import java.util.List;

/**
 * <pre>
 * 业务菜单服务
 * </pre>
 * @author megapro
 *
 */
public interface ISysDictService extends IService<SysDict> {
    /**
     * <pre>
     * 新增业务字典
     * 系统自动补充guid
     *
     * </pre>
     * @param  sysDict
     * @return 新增的业务字典记录
     * @throws SysManagementException
     */
    SysDict addDict(SysDict sysDict) throws SysManagementException;

    /**
     * <pre>
     * 查询指定dictKey对应的业务字典信息（包括子业务字典信息）
     * 一次查询可获取的信息包括：
     * 1. 业务字典
     * 2. 字典项
     * 3. 子业务字典
     *
     * </pre>
     * @param id 字典KEY
     * @return 字典信息视图对象(SysDictDetail)
     * @throws SysManagementException
     */
    SysDict queryDictDetail( String id ) throws SysManagementException;

    /**
     * <pre>
     * 查询指定dictKey对应的业务字典信息（本身内容）
     * 一次查询可获取的信息包括：
     * 1. 业务字典
     * 2. 字典项
     *
     * </pre>
     * @param id 字典KEY
     * @return 对应字典（SysDict）
     * @throws SysManagementException
     */
    List<SysDict> queryDict( String id ) throws SysManagementException;

    /**
     * 修改业务字典
     * @param sysDict
     * @throws SysManagementException
     */
    SysDict editSysDict(SysDict sysDict) throws SysManagementException;


    /**
     * 根据业务字典GUID删除业务字典
     *
     * @param id
     * 			业务字典GUID
     * @throws SysManagementException
     */
    void deleteDict(String id) throws SysManagementException;

    /**
     * 根据业务字典guid批量删除业务字典
     * @param sysDictDelRequest
     * @return
     * @throws SysManagementException
     */
    List<SysDict> deleteDictList(SysDictDelRequest sysDictDelRequest) throws SysManagementException;

    /**
     * 查询所有业务字典
     *
     * @param
     * @return
     * @throws SysManagementException
     */
    Page<SysDict> querySysDicts(Page<SysDict> page, Wrapper<SysDict> wrapper) throws SysManagementException;

    /**
     * 查询所有的父业务字典,并不分页
     *
     * @return
     * @throws SysManagementException
     */
    List<SysDict> queryParentList()throws SysManagementException;

    /**
     * 根据GUID查询业务字典自身
     * @param id
     * 			业务字典GUID
     * @return
     * @throws SysManagementException
     */
    SysDict queryOneSysDictByGuid(String id) throws SysManagementException;


    /**
     * 设置业务字典的默认字典项
     *
     * @param sysDict 字典GUID
     * @return
     * @throws SysManagementException
     */
    List<SysDict> dictKeyQuery(SysDict sysDict) throws SysManagementException;
    /**
     * 设置业务字典的默认字典项
     *
     * @param id 字典GUID
     * @return
     * @throws SysManagementException
     */
    SysDict querySysDictByGuid(String id) throws SysManagementException;

    /**
     * 查询业务字典的树结构
     * @param id
     * @return
     * @throws SysManagementException
     */
    SysDictHandelDetail queryDictTree(String id) throws SysManagementException;

    /**
     * 过滤查询业务字典的树结构
     * @param filterQueryRequest
     * @return
     * @throws SysManagementException
     */
    SysDictHandelDetail filterQueryDictTree(SysDictFilterQueryRequest filterQueryRequest) throws SysManagementException;

    /**
     * 设置默认字典项
     * @param sysDictDefaultValueRequest
     * @return
     * @throws SysManagementException
     */
    SysDict setDefaultValue(SysDictDefaultValueRequest sysDictDefaultValueRequest) throws SysManagementException;

    /**
     * 根据key值查询业务字典
     * @param dictKey
     * @return
     * @throws SysManagementException
     */
    SysDict queryDictByKey(String dictKey)throws SysManagementException;

    /**
     *
     * @param id
     * @return
     * @throws SysManagementException
     */
    List<SysDict> queryDictExcept(String id)throws SysManagementException;

    /**
     * 为外部服务提供
     * 根据key值查询子字典和字典项
     */
    List<SysDictApiDetail> queryDictSon(String dictKey)throws SysManagementException;

    /**
     * 判断 key值是否已经存在
     */
    Boolean existAddDictKey(String dictKey)throws SysManagementException;

    /**
     * 判断 key值是否已经存在
     */
    Boolean existUpdateDictKey(String dictKey,String guid)throws SysManagementException;

    /**
     * 对外服务
     * 查询业务字典
     *
     * @param page 分页信息
     * @param wrapper 查询参数
     * @return 返回业务字典列表
     * @throws SysManagementException 系统异常
     */
    Page<SysDictDetail> getSysDict(Page<SysDict> page, Wrapper<SysDict> wrapper) throws SysManagementException;
}
